//
//  TFUrlAlertView.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/4/21.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TFUrlAlertView: UIView {
    
    @objc public var urlLab = UILabel()
    @objc public var commitBtn = UIButton()
    @objc public var closeBtn = UIButton()
    @objc public var cancelBtn = UIButton()

    @objc public var titleLab = UILabel()
    @objc public var urlView = UIView()
    @objc public var gl = CAGradientLayer()
    @objc public var glview = UIView()

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.titleLab.textColor = UIColor(red: 20/255.0, green: 23/255.0, blue: 26/255.0, alpha: 1)
        self.titleLab.numberOfLines = 0
        self.titleLab.font = UIFont.PingFang(size: 18)
        self.titleLab.text = "你将要访问网站"
        self.titleLab.textAlignment = .center
        self.addSubview(self.titleLab)
        

        self.urlView.backgroundColor = UIColor(red: 243/255.0, green: 244/255.0, blue: 245/255.0, alpha: 1)
        self.addSubview(self.urlView)
        
        self.urlLab.textColor = UIColor(red: 20/255.0, green: 23/255.0, blue: 26/255.0, alpha: 1)
        self.urlLab.font = UIFont.PingFang(size: 15)
    
        self.urlLab.textAlignment = .center
        self.urlView.addSubview(self.urlLab)
      
        self.commitBtn.setTitle("确认", for: .normal)
        self.commitBtn.titleLabel!.font = UIFont.PingFang(size: 17)
        self.commitBtn.setTitleColor(UIColor.white, for: .normal)
        self.commitBtn.backgroundColor = UIColor(red: 65/255.0, green: 150/255.0, blue: 235/255.0, alpha: 1)
        
        self.addSubview(self.commitBtn)
        
        self.cancelBtn.setTitle("取消", for: .normal)
        self.cancelBtn.titleLabel!.font = UIFont.PingFang(size: 17)
        self.cancelBtn.setTitleColor(UIColor(red: 150/255.0, green: 150/255.0, blue: 235/255.0, alpha: 1), for: .normal)
     
        self.addSubview(self.cancelBtn)
        
        self.closeBtn.setImage(UIImage.init(named: "HTLive.bundle/close_gray"), for: .normal)
        
        self.addSubview(self.closeBtn)
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func closeBtnClick()
    {
        self.removeFromSuperview()
       
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        self.closeBtn.frame = CGRect(x: self.frame.size.width-40, y: 10, width: 30, height: 30)
        
        self.titleLab.frame = CGRect(x: 0, y: 40, width: self.frame.size.width, height: 25)

        
        self.urlView.frame = CGRect(x: 32, y: self.titleLab.frame.maxY+24, width: self.frame.size.width-64, height: 40)
        
        
        self.urlLab.frame = CGRect(x: 17, y: 9, width: self.urlView.frame.size.width-34, height: 22)
       
        self.commitBtn.frame = CGRect(x: 32, y: self.urlView.frame.maxY+24, width: self.frame.size.width-64, height: 40)
       

        self.cancelBtn.frame = CGRect(x: 32, y: self.commitBtn.frame.maxY+5, width: self.frame.size.width-64, height: 40)
 
    }
}
